
/**
 * 作者：李广彬
 * 版本：1.0
 * 参数：消息   类型
 */
(function($) {
	
	$.bfecAlert = {
		_alert: function(message,type,params) {
			if( type == null ) type = '0';
			$.bfecAlert._show(message,type,params);
		},
		_show: function(msg,type,params) {
			$("#_alert_info").show();
			if($("#_alert_info").html()==undefined){
				$("body").append($.bfecAlert._html());
			}
				
			$("#_alert_info span[name='alert_title']").text("提示消息");
			var typeCss="alert_infoPic";
			switch(type) {
				case 0://正常
					typeCss="alert_infoPic";
				break;
				case 1://成功
					typeCss="alert_successPic";
				break;
				case 2://失败
					typeCss="alert_errorPic";
				break;
				case 3://警告
					typeCss="alert_warnPic";
				break;
			}
			$("#_alert_info div[name='alert_msg']").removeClass();
			$("#_alert_info div[name='alert_msg']").addClass(typeCss);
			$("#_alert_info div[name='alert_msg']").text(msg);
			$("#_alert_info span[name='alert_close']").unbind();
			$("#_alert_info input[name='alert_submit']").unbind();
			$("#_alert_info span[name='alert_close']").click(function(){
				$.bfecAlert._hide(this);
			});
			$("#_alert_info input[name='alert_submit']").click(function(){
				$.bfecAlert._hide(this);
			});
			
			$.bfecAlert._position($("#_alert_info .altTc_tcC5"),params);
			
			$("#_alert_info").show();
		},
		_hide: function(thisObj) {
			$(thisObj).parents(".altTc_tcDiv").hide();
		},
		_position: function(positionObj,params) {
			var sTop=document.documentElement.scrollTop || document.body.scrollTop;
			var cWidth=document.documentElement.clientWidth || document.body.clientWidth;
			var cHeight=document.documentElement.clientHeight || document.body.clientHeight;
			var POWidth=$(positionObj).width();
			var POHeight=$(positionObj).height();
			var cLeft=(cWidth-POWidth)/2;
			var cTop=(cHeight-POHeight)/2;
			cLeft=cLeft>0?cLeft:0;
			cTop=cTop>0?cTop+sTop:sTop;
			$(positionObj).css("left",cLeft+"px").css("top",cTop+"px");
			if(params){
				if(params.X){
					$(positionObj).css("left",params.X+"px");
				}
				if(params.Y){
					$(positionObj).css("top",params.Y+"px");
				}
			}
		},
		_html: function() {
			var html=   '<div class="altTc_tcDiv" id="_alert_info">'+
						'  <div class="altTc_tcD_bg"></div>'+
						'  <div class="altTc_tcC5">'+
						'   <div class="altTc_tcT2">'+
						'		<span class="r" name="alert_close"></span><span class="l" name="alert_title">提示消息</span>'+
						'	</div>'+
						'	<div class="altTc_tcM2 fix">'+
						'	  <div class="altTc_tcR2">'+
						'		<div class="altTc_tc2_ct fix">'+
						'		  <div style="margin:auto;text-align:center; line-height:22px; color:#5a5a5a; font-size:14px; ">'+
						'			  <div name="alert_msg" style="display:inline">关注成功</div>'+
						'		  </div>'+
						'		  <div class="fix" align="center">'+
						'			  <input type="button" class="altTc_sub1" name="alert_submit" value="确定">'+
						'		  </div>'+
						'		</div>'+
						'	  </div>'+
						'	</div>'+
						'    <div class="altTc_tcB2"></div>'+
						'  </div>'+
						'</div>';
			
			return html;
		}
	};
	
	bfecAlert = function(msg,type,params) {
		$.bfecAlert._alert(msg,type,params);
	};	
})(jQuery);

$(function() {
	window.winAlert = window.alert;
	window.alert = function(msg, optType,params) {
		bfecAlert(msg, optType,params);
	};
	window.pAlert = function(msg, optType,params) {
		window.parent.alert(msg, optType,params);
	};
});